package com.example.amone;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.example.amone.adapter.GroupAdapter;
import com.example.amone.adapter.MenuAdapter;
import com.example.amone.bean.GroupBean;
import com.example.amone.bean.MenuBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 产品如何创造出来
 */
public class Business implements IBusiness, MenuAdapter.OnMenuItemListener {

    private static final String TAG = Business.class.getSimpleName();
    private Context context;
    private RecyclerView menuGroup, rlAllMenu, rlMenu;
    private GroupAdapter groupAdapter;
    private MenuAdapter menuAdapter;

    public Business(Context context, RecyclerView menuGroup, RecyclerView rlAllMenu, RecyclerView rlMenu) {
        this.context = context;
        this.menuGroup = menuGroup;
        this.rlAllMenu = rlAllMenu;
        this.rlMenu = rlMenu;
        initAdapter();
    }

    public void setData(List<GroupBean> groupBeanList, List<MenuBean> menuBeanList) {
        groupAdapter.setGroupList(groupBeanList);
        menuAdapter.setMenuList(menuBeanList);
    }

    private void initAdapter() {
        if (groupAdapter == null)
            groupAdapter = new GroupAdapter(context);
        if (menuAdapter == null)
            menuAdapter = new MenuAdapter(context);
        menuAdapter.setOnMenuItem(this);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        menuGroup.setLayoutManager(linearLayoutManager);
        menuGroup.setAdapter(groupAdapter);

        GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 7);
        rlAllMenu.setLayoutManager(gridLayoutManager);
        rlAllMenu.setAdapter(menuAdapter);

    }


    @Override
    public List<MenuBean> order() {
        List<MenuBean> list = new ArrayList<>();
        Log.d(TAG, "下单");
        return list;
    }

    @Override
    public void delete() {
        Log.d(TAG, "删除");
    }

    @Override
    public void service(String telId) {
        Log.d(TAG, "服务电话" + telId);
    }

    @Override
    public void onMenuListener() {

    }
}
